﻿using System;
using System.Threading;
using System.Windows;
using System.Windows.Media.Animation;

namespace MyAnimelistRecommender
{
    /// <summary>
    /// Interaktionslogik für Splash.xaml
    /// </summary>
    public partial class Splash : Window
    {
        public Splash()
        {
            InitializeComponent();
            Loaded += Window_Loaded;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var disp = Dispatcher;
            new Thread(() =>
            {
                Thread.Sleep(
                    4200);
                Dispatcher.Invoke((Action)delegate
                {
                    if (StarteEndlichEvent != null)
                    {
                        StarteEndlichEvent(this, null);

                        this.Close();
                        Dispatcher.InvokeShutdown();
                    }
                });
            }).Start();
        }

        public event EventHandler StarteEndlichEvent;

        private void Storyboard_Completed(object sender, EventArgs e)
        {
            ((Storyboard)FindResource("Storyboard1")).Begin();
        }

        private void Storyboard_Completed_1(object sender, EventArgs e)
        {
            //   this.Close();
            // Dispatcher.InvokeShutdown();
            //  ((Storyboard)FindResource("loop")).Begin();
        }
    }
}